cmake_minimum_required(VERSION 3.8)
project(rm_draw_img)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 查找依赖包
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

# 显式查找关键包（确保目标被正确导出）
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(message_filters REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(OpenCV REQUIRED)
find_package(rm_interfaces REQUIRED)
find_package(image_transport REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(Eigen3 REQUIRED)  # 替换原来的 find_package(eigen REQUIRED)


# 添加可执行文件
add_executable(rm_draw_img src/draw_img_node.cpp)

# 包含目录
target_include_directories(rm_draw_img PRIVATE
  ${rclcpp_INCLUDE_DIRS}
  ${std_msgs_INCLUDE_DIRS}
  ${sensor_msgs_INCLUDE_DIRS}
  ${message_filters_INCLUDE_DIRS}
  ${cv_bridge_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ${rm_interfaces_INCLUDE_DIRS}
  ${image_transport_INCLUDE_DIRS}
)

# 链接库（使用ament_target_dependencies替代）
ament_target_dependencies(rm_draw_img
  "rclcpp"
  "std_msgs"
  "sensor_msgs"
  "message_filters"
  "cv_bridge"
  "rm_interfaces"
  "image_transport"
  "tf2_ros"
  "tf2_geometry_msgs"
)

# 单独链接OpenCV
target_link_libraries(rm_draw_img
  ${OpenCV_LIBRARIES}
  Eigen3::Eigen  # 自动处理头文件路径
)

# 安装目标
install(TARGETS rm_draw_img
  DESTINATION lib/${PROJECT_NAME}
)

ament_package()